import vue from '@vitejs/plugin-vue'

import createAutoImport from './auto-import'
// import createSvgIcon from './svg-icon'
import createCompression from './compression'
import createSetupExtend from './setup-extend'
// import createVisualizer from './visualizer'
// import createEslint from './eslint'
// const lifecycle = process.env.npm_lifecycle_event

export default function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins = [vue()]
  vitePlugins.push(createAutoImport())
  vitePlugins.push(createSetupExtend())
  // vitePlugins.push(createEslint())
  // vitePlugins.push(createSvgIcon(isBuild))
  // 只有在build:report命令下才配置打包分析插件
  // if (lifecycle === 'build:report') {
  //   vitePlugins.push(createVisualizer())
  // }
  isBuild && vitePlugins.push(...createCompression(viteEnv))
  return vitePlugins
}
